# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=ruby-rmagick
_gemname=rmagick
pkgver=4.1.2
_pkgver=${pkgver//./-}
pkgrel=0
pkgdesc="Ruby bindings for ImageMagick"
url="https://github.com/rmagick/rmagick"
arch="all !mips64" # testsuite fails on mips64
license="MIT"
depends="ghostscript-fonts"
checkdepends="ruby-rake ruby-rspec"
makedepends="imagemagick6-dev ruby ruby-dev"
source="https://github.com/rmagick/rmagick/archive/RMagick_$_pkgver.tar.gz
	gemspec.patch
	spec-drop-pry.patch
	dont-test-webp.patch
	"
builddir="$srcdir/rmagick-RMagick_$_pkgver"

build() {
	gem build $_gemname.gemspec
	gem install --local \
		--install-dir dist \
		--ignore-dependencies \
		--no-document \
		--verbose \
		$_gemname
}

check() {
	GEM_PATH='dist:.gem' rspec
}

package() {
	local gemdir="$pkgdir/$(ruby -e 'puts Gem.default_dir')"
	cd "$builddir"/dist

	mkdir -p "$gemdir"
	cp -r extensions gems specifications "$gemdir"/

	# Remove unnecessary files and rubbish...
	find "$gemdir"/extensions/ -name mkmf.log -delete

	cd "$gemdir"/gems/$_gemname-$pkgver
	rm -r ext/ lib/*.so
}

sha512sums="671ce8ef0d2387d6f0091a7a7a79a5ee9a5c5cd9340f5d29b4a35227c2293eae5e0e5c9ef16a83dc24ed0cb59cc7258427f8880484f7bb49dfaccb00d280e2b4  RMagick_4-1-2.tar.gz
9a5dccceb069d0b274256c181335ac92037d0def3b3ed4e087f1eec1f7e9a9d07f9105bec87f732828c3bdff96b7032ffd696d6b9b4941748b0b64315d11d253  gemspec.patch
c6fa08e68a4cd94bdcee2e83144845862a49c86fdbaccd500af6459e09092f0a7bb03352875e73a20a9fc5474f4376df378aea6a61415fdf249b4e9de5c95266  spec-drop-pry.patch
5eeea508d44f2c9679fe4fe3d5b9a51470f8022537f5822f85c95dbd4d78149c2cada763f0bdf3e86523770b0b758117a6d216b240c92f54253905c19d38d064  dont-test-webp.patch"
